package com.zxl.admin.context;


import com.zxl.common.model.pojo.SysUser;

/**
 * 用户上下文
 */
public class UserContext {

    private static final ThreadLocal<Integer> userHolder = new ThreadLocal();
    private static final ThreadLocal<String> userCode = new ThreadLocal<>();
    private static final ThreadLocal<SysUser> userInfo = new ThreadLocal<>();

    public static SysUser getUser(){
        return userInfo.get();
    }

    public static void setUser(SysUser user){
        userInfo.set(user);
    }

    public static Integer getUserId() {
        return userHolder.get();
    }

    public static void setUserId(Integer userId) {
        userHolder.set(userId);
    }

    public static String getUserCode(){
        return userCode.get();
    }

    public static void setAccount(String account){
        userCode.set(account);
    }

    public static void clearContext() {
        userHolder.remove();
        userCode.remove();
        userInfo.remove();
    }



}
